<html>
<head><meta charset="utf-8"><title>Help with redundant_pub lint · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Help.20with.20redundant_pub.20lint.html">Help with redundant_pub lint</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217495759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Help%20with%20redundant_pub%20lint/near/217495759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Help.20with.20redundant_pub.20lint.html#217495759">(Nov 21 2020 at 10:32)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![warn(unreachable_pub)]</span><span class="w"></span>
<span class="cp">#![warn(clippy::redundant_pub_crate)]</span><span class="w"></span>
<span class="k">mod</span> <span class="nn">internal</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="p">(</span><span class="k">crate</span><span class="p">)</span><span class="w"> </span><span class="k">fn</span> <span class="nf">reexported</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">pub</span><span class="p">(</span><span class="k">crate</span><span class="p">)</span><span class="w"> </span><span class="k">use</span><span class="w"> </span><span class="n">internal</span>::<span class="o">*</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">reexported</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Could someone help me understand if this lint makes sense? With the code as written, <code>reexported</code> is flagged by the <code>redundant_pub_crate</code> lint, saying that it is silly to write <code>pub(crate)</code> on something in an internal module because it's actually private. It claims that you can write either <code>pub</code> or private instead, but <code>pub</code> triggers the <code>unreachable_pub</code> lint instead (which seems to have similar reasoning), and private is a compile error because the re-export doesn't work.</p>



<a name="217495839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Help%20with%20redundant_pub%20lint/near/217495839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Help.20with.20redundant_pub.20lint.html#217495839">(Nov 21 2020 at 10:34)</a>:</h4>
<p>(Setting aside the sanity of the lints, what is the idiomatic way to do this? The re-export is done so that we can stub out the entire module under some cfg settings.)</p>



<a name="217498513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Help%20with%20redundant_pub%20lint/near/217498513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Help.20with.20redundant_pub.20lint.html#217498513">(Nov 21 2020 at 11:51)</a>:</h4>
<p>I think that the clippy lint has a false positive here, it shouldn't be linting on the example given</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>